package com.jwdf.uda.ui.fragment.question.bean;

import android.content.Context;
import android.util.Log;
import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.bean.UploadImage;
import java.io.File;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/9/5.
 */
public class NewProblems implements Serializable {

    private Context mContext;
    private static NewProblems instance = null;
    int questionId;
    private String mNick;
    private String mDescribe;
    private List<NewVote> mNewVoteList = new ArrayList<>();
    private List<UploadImage> mDescriptionImageToken = new ArrayList<>();
    private List<EditDescribe> editDescribeList = new ArrayList<>();
    private List<String> imageList = new ArrayList<>();
    private Map<String, String> mURLToken = new HashMap<>();
    private int mTag = 10;
    private boolean mIsUpload=true;
    private List<File> imageFileList =new ArrayList<>();
    private Map<String, String> mTagMap=new HashMap<>();
    public static synchronized NewProblems getInstance() {
        if(instance == null) {
            Log.i("----NewProblems 数据空", "NewProblems----------------------");
            instance = new NewProblems();
        }
        return instance;
    }
    public NewProblems(){

    }
    public String getmDescribe() {
        return mDescribe;
    }


    public void setmDescribe(String mDescribe) {
        this.mDescribe = mDescribe;
    }

    public String getmNick() {
        return mNick;
    }

    public void setmNick(String mNick) {
        this.mNick = mNick;
    }

    public List<NewVote> getNewVoteList() {
        return mNewVoteList;
    }

    public void setNewVoteList(List<NewVote> mNewVoteList) {
        this.mNewVoteList = mNewVoteList;
    }

    public List<UploadImage> getDescriptionImageToken() {
        return mDescriptionImageToken;
    }

    public void setDescriptionImageToken(List<UploadImage> mDescriptionImageToken) {
        this.mDescriptionImageToken = mDescriptionImageToken;
    }

    public void deleteNewVote() {
        mNewVoteList.clear();
    }

    public void setAddImageToken(UploadImage uploadImage) {
        mDescriptionImageToken.add(uploadImage);
    }

    public int getTag() {
        return mTag;
    }
    public void setTag(int mTag) {
        this.mTag = mTag;
    }
    public List<EditDescribe> getEditDescribeList() {
        return editDescribeList;
    }
    public void setEditDescribeList(EditDescribe editDescribeList) {
        this.editDescribeList.add(editDescribeList);
    }
    public void setEditDescribeList(List<EditDescribe> editDescribeList) {
        this.editDescribeList = editDescribeList;
    }
    public void deleteNewProblems() {
        mNick = "";
        mDescribe = "";
        mNewVoteList.clear();
        mDescriptionImageToken.clear();
        mTag = 10;
        mURLToken.clear();
        mIsUpload=true;
        imageFileList.clear();
//        mContext=null;
    }

    public List<String> getImageList() {
        return imageList;
    }

    public void setImageList(List<String> imageList) {
        this.imageList = imageList;
    }

    public void deleteEditDescribeList() { editDescribeList.clear(); }

    public int getQuestionId() {
        return questionId;
    }

    public void setQuestionId(int questionId) {
        this.questionId = questionId;
    }

    private Object readResolve() throws ObjectStreamException {
        return instance;
    }

    public String getURLToken(String url) {
        return mURLToken.get(url);
    }

    public void setURLToken(String url, String token) {
        this.mURLToken.put(url, token);
    }

    public void setURLToken(Map<String, String> mURLToken) { this.mURLToken = mURLToken; }


    public Context getContext() {
        return mContext;
    }

    public void setContext(Context mContext) {
        this.mContext = mContext;
    }

    public void emptyContext(){
        this.mContext=null;
    }

    public boolean ismIsUpload() {
        return mIsUpload;
    }

    public void setmIsUpload(boolean mIsUpload) {
        this.mIsUpload = mIsUpload;
    }

    public List<File> getImageFileList() {
        return imageFileList;
    }

    public void setImageFileList(List<File> imageFileList) {
        this.imageFileList = imageFileList;
    }

    public void addImageFileList(File file,int i){
        this.imageFileList.add(i,file);
    }

    public void setTagMap(PbBean.PbResQuestionCategoryGet categoryGet){
        mTagMap.clear();
        for(int i=0;i<categoryGet.getCategoryInfoCount();i++){
            mTagMap.put(categoryGet.getCategoryInfo(i).getCategoryCode()+"",categoryGet.getCategoryInfo(i).getCategoryName());
        }
    }
    public int getIntTag(int code,int count){
        Iterator iter = mTagMap.entrySet().iterator();
        int i=0;
        int tag=0;
        while (iter.hasNext()) {
            i++;
            Map.Entry entry = (Map.Entry) iter.next();
            if(entry.getKey().equals(code+"")){
                tag=i;
            }
        }
        return tag;
    }
}
